package com.sinosoft.hydra.um.services;

import com.sinosoft.hydra.um.domain.permission.SysUserSecurityType;
import com.sinosoft.hydra.um.repositories.SysUserSecurityTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 加密设置服务类
 * @author liangminga
 * @since 0.5-alpha
 * 2015年1月6日
 */
@Service
public class SysUserSecurityTypeService {
    /**
     * 加密设置持久化类
     */
    @Autowired
    private SysUserSecurityTypeRepository sysUserSecurityTypeRepository;
    /**
     * 获取加密方式
     * @return SysUserSecurityType 加密类型对象
     */
    public SysUserSecurityType getSysUserSecurityType(){
        return sysUserSecurityTypeRepository.findAll().size()==0?null:sysUserSecurityTypeRepository.findAll().get(0);
    }

    /**
     * 配置加密方式
     * @param resource 加密类型对象
     * @return Map<String,Object> 哈希对象
     */
    public SysUserSecurityType updateSysUserSecurityType(SysUserSecurityType resource){
        SysUserSecurityType sysUserSecurityType = sysUserSecurityTypeRepository.save(resource);
        return sysUserSecurityType;
    }
}
